# game constants
from constants import *

# cocos componets used by this scene
from cocos.director import director
from cocos.scene import Scene
from cocos.layer import Layer, ColorLayer
from cocos.scenes.transitions import *
from cocos.actions import *
from cocos.sprite import Sprite
from cocos.text import Label
from cocos.menu import *

# pyglet  componets used by this scene
import pyglet
from pyglet import gl, font
from pyglet.window import key

from scene_galaxy import *

class MenuLayer(Menu):

    is_event_handler = True     #: enable pyglet's events

    def __init__( self, interface ):
        # call the parent's constructor
        super(MenuLayer, self).__init__("- Game title here -")

        # keep track of the interface
        self.interface = interface

        self.menu_valign = CENTER
        self.menu_halign = CENTER

        # then add the items
        items = [
            ( MenuItem('New Game', self.on_start_new ) ), 
            ( MenuItem('Load Game', self.on_dummy ) ),
            ( MenuItem('Options', self.on_dummy ) ),
            ( MenuItem('Credits', self.on_dummy ) ),
            ( MenuItem('Quit', self.on_quit ) ),

        ]

        self.create_menu( items, shake(), shake_back() )
        
    def on_quit(self):
        pyglet.app.exit()

    def on_dummy(self):
        pass
        
    def on_start_new(self):
        self.interface.game.newGame(random.randint(0,1000))
        galaxyScene = GalaxyScene(self.interface)
        director.push(galaxyScene)

def MainMenuScene(interface):
    # in this generic example, build a scene composed by only one layer
    return Scene( MenuLayer(interface) )




